package com.right.health.app.ui.registered.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.magic.basic.adapter.BaseRecyclerAdapter;
import com.right.health.app.R;
import com.right.health.app.bean.DepartmentInfo;

/*
 * Created by hopeliao on 2019-09-25
 *
 */
public class DepartmentRightAdapter extends BaseRecyclerAdapter<DepartmentInfo, RecyclerView.ViewHolder>  {

    public DepartmentRightAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindViewHolderEx(RecyclerView.ViewHolder viewHolder, int i) {
        ItemViewHolder holder = (ItemViewHolder) viewHolder;
        DepartmentInfo response = mDataSource.get(i);
        holder.nameTv.setText(response.deptname);
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View convertView = mInflater.inflate(R.layout.choose_department_right_child_item, parent, false);

        RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) convertView.getLayoutParams();

        lp.width = RecyclerView.LayoutParams.MATCH_PARENT;
        lp.height = RecyclerView.LayoutParams.WRAP_CONTENT;

        convertView.setLayoutParams(lp);
        return new ItemViewHolder(convertView);
    }


    private class ItemViewHolder extends RecyclerView.ViewHolder {

        private TextView nameTv;
        ItemViewHolder(View convertView) {
            super(convertView);
            nameTv = (TextView) convertView.findViewById(R.id.tv_name);
        }

    }
}
